home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 6
/
FM Towns Free Software Collection 6.iso
/
t_os
/
igo
/
src
/
display.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-08
|
5KB
|
199 lines
#define DEBUG 0
/*
TOWNS囲碁棋譜記録プログラム
1991/12/11 久保田俊也
91/12/11 display モジュールを本体より分離
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winb.h>
#include <egb.h>
#include <te.h>
#include <fntb.h>
#include <gui.h>
#include "igo.h"
#include "ban19.h"
static char save_ban[BANSIZE2];
static int banx1, bany1, banx2, bany2, ishi_r, ishi_2r;
char *gwork; /* グラフイックBIOSワーク */
char para[64] ;
int disp_init()
{
gwork = MMI_GetEgbPtr();
EGB_writePage( gwork, 1 ) ; /* ページ 1 に */
EGB_color( gwork, 0, 5 ) ; /* 色を青(5)にして */
EGB_color( gwork, 2, 5 ) ; /* 色を青(5)にして */
EGB_paintMode( gwork, 0x022 );
EGB_box( gwork, 0, 0, 640, 480 ); /* [46] 四角を描く */
disp_goban(BANX, BANY, ISHI_R);
ban_init(19,save_ban);
EGB_writePage( gwork, 0 ) ; /* ページ 0 に */
EGB_setPalette( gwork, BLACK_COL, 0, 0, 0 ); /* [04] */
return 0;
}
int disp_goban(int x, int y, int z)
{
int i, j ;
banx1 = x;
bany1 = y;
ishi_r = z;
ishi_2r = ishi_r * 2;
banx2 = banx1 + (19+1)*ishi_2r;
bany2 = bany1 + (19+1)*ishi_2r;
EGB_color( gwork, 0, 6 ) ; /* 色を黄(6)にして */
EGB_color( gwork, 2, 6 ) ; /* 色を黄(6)にして */
EGB_paintMode( gwork, 0x022 );
EGB_box( gwork, banx1, bany1, banx2, bany2); /* [46] 四角を描く */
EGB_color( gwork, 0, 1 ) ;
EGB_color( gwork, 2, 1 ) ;
for ( i = 0; i < 19; i++){
EGB_singleLine( gwork, (i+1)*ishi_2r+banx1, bany1+ishi_2r,
(i+1)*ishi_2r+banx1, bany2-ishi_2r) ;
EGB_singleLine( gwork, banx1+ishi_2r, bany1+(i+1)*ishi_2r,
banx2-ishi_2r, bany1+(i+1)*ishi_2r) ;
}
for ( i = 0; i < 3; i++){
for ( j = 0; j < 3; j++){
WORD(para + 0) = 6*ishi_2r*i+banx1+4*ishi_2r;
WORD(para + 2) = 6*ishi_2r*j+bany1+4*ishi_2r;
WORD(para + 4) = 2;
EGB_circle( gwork, para ) ; /* その位置に点を描く */
}
}
return 0;
}
int disp_te(char ban[BANSIZE2],int ex_ban[BANSIZE2])
{
int i;
char s[4];
int stonex, stoney;
static int save_ex_ban[BANSIZE2];
MG_mosDisp( 2 ) ; /* マウスを表示 シナイ */
EGB_paintMode( gwork, 0x022 ); /* 設定しないといけない? */
for(stoney=1;stoney<(BANSIZE+1);stoney++){
for(stonex=1;stonex<(BANSIZE+1);stonex++){
if( ban[stonex + stoney*(BANSIZE+1)] != save_ban[stonex + stoney*(BANSIZE+1)] ||
ex_ban[stonex + stoney*(BANSIZE+1)] != save_ex_ban[stonex + stoney*(BANSIZE+1)]){
switch(ban[stonex + stoney*(BANSIZE+1)]){
case BLACK:
EGB_color( gwork, 0, 1);
EGB_color( gwork, 2, BLACK_COL);
gcircle((stonex)*ishi_2r+banx1, (stoney)*ishi_2r+bany1,
ishi_r);
break;
case WHITE:
EGB_color( gwork, 0, 1 ) ;
EGB_color( gwork, 2, WHITE_COL);
gcircle((stonex)*ishi_2r+banx1, (stoney)*ishi_2r+bany1,
ishi_r);
break;
case BLANK:
EGB_color( gwork, 0, 0 ) ;
EGB_color( gwork, 2, 0 ) ;
EGB_box( gwork,
(stonex)*ishi_2r+banx1-ishi_r,
(stoney)*ishi_2r+bany1-ishi_r,
(stonex)*ishi_2r+banx1+ishi_r,
(stoney)*ishi_2r+bany1+ishi_r);
/* [46] 四角を描く */
break;
}
switch(ban[stonex+stoney*(BANSIZE+1)]){
case BLANK:
break;
case BLACK:
EGB_color( gwork, 0, WHITE_COL) ;
EGB_color( gwork, 2, WHITE_COL) ;
break;
case WHITE:
EGB_color( gwork, 0, BLACK_COL) ;
EGB_color( gwork, 2, BLACK_COL) ;
break;
}
if(ban[stonex+stoney*(BANSIZE+1)] != -1){
if(ex_ban[stonex+stoney*(BANSIZE+1)] >= 100){
s[0] = '0' + ex_ban[stonex+stoney*(BANSIZE+1)]/100;
s[1] = '0' + (ex_ban[stonex+stoney*(BANSIZE+1)]%100)/10;
s[2] = '0' + (ex_ban[stonex+stoney*(BANSIZE+1)]%10);
s[3] = '\0';
gprint(s, (stonex)*ishi_2r+banx1-12,
(stoney)*ishi_2r+bany1+8);
}else if(ex_ban[stonex+stoney*(BANSIZE+1)] >= 10){
s[0] = '0' + ex_ban[stonex+stoney*(BANSIZE+1)]/10;
s[1] = '0' + (ex_ban[stonex+stoney*(BANSIZE+1)]%10);
s[2] = '\0';
gprint(s, (stonex)*ishi_2r+banx1-8,
(stoney)*ishi_2r+bany1+8);
}else if(ex_ban[stonex+stoney*(BANSIZE+1)] >= 1){
s[0] = '0' + (ex_ban[stonex+stoney*(BANSIZE+1)]%10);
s[1] = '\0';
gprint(s, (stonex)*ishi_2r+banx1-4,
(stoney)*ishi_2r+bany1+8);
}
}
}
}
}
for(i=0;i<BANSIZE2;i++){
save_ban[i] = ban[i];
save_ex_ban[i] = ex_ban[i];
}
MG_mosDisp( 3 ) ; /* マウスを表示する */
return 0;
}
int gprint( char *p, int x, int y)
{
int i;
char dsp[70];
WORD(dsp+0) = x;
WORD(dsp+2) = y;
for(i=0;i<64;i++){
dsp[i+6] = (char)(BYTE(p+i));
if(dsp[i+6] == (char)0 ){
break;
}
}
WORD(dsp+4) = i;
EGB_writeMode(gwork, 0);
EGB_sjisString(gwork, dsp);
return i;
}
int gcircle(int x, int y, int r)
{
WORD(para + 0) = x;
WORD(para + 2) = y;
WORD(para + 4) = r;
EGB_circle( gwork, para ) ;/* その位置に点を描く */
return 0;
}